<admintpl file="header" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/ueditor/third-party/video-js/video-js.min.css"/>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/third-party/video-js/video.js"></script>
<script src="http://cdn.bootcss.com/html5media/1.1.8/html5media.min.js"></script>
<script src="http://api.html5media.info/1.1.4/html5media.min.js"></script>
<style type="text/css">
	.zu_span3{
		width:0px;
	}
	.control-label{
		margin-left:0px;
		text-align: left;
	}
</style>
</head>
<body>

<div class="wrap">
	<form method="post" class="form-horizontal" id="pub_form" action="{:U('Vote/addClass')}"
		  enctype="multipart/form-data">

		<div class="control-group" >
			<label class="span1 control-label" style="width: 90px;">添加类：</label>
			<div class="span3"  id="chengban">
				<?php if($info){?>
				<input type="hidden" name="edit" value="1">
				<?php foreach($info as $k=>$v){ ?>
					<input type="text" name="vote_class[<?php echo $v['class_id'];?>]" style="width: 556px; margin-top: 5px;" value="<?php echo $v['class_name'];?>" class="vote_class">
					<div class="control-group" style="margin-top:20px;">
						<label class="span1 control-label" style="width: 60px;text-align: left;">选择组：</label>
							<div class="zu_span3">
								<select class="select_2" name="parent_id[<?php echo $v['class_id'];?>]" id="column_type" >
									<?php foreach($group_arr as $key=>$val){?>
										<option name="g_id" <?php if($v['parent_id'] == $val['class_id']){echo "selected='selected'";}?> value="<?php echo $val['class_id'];?>">
										<?php echo $val['class_name'];?></option>
									<?php } ?>
								</select>
							</div>
					</div>
				<?php } ?>
				<?php }else{ ?>
					<input type="text" name="vote_class[]" style="width: 556px;" value="" class="vote_class">
					<div class="control-group" style="margin-top:20px;">
						<label class="span1 control-label" style="width: 60px;text-align: left;">选择组：</label>
						<div class="zu_span3">
							<select class="select_2" name="parent_id[]" id="column_type" >
								<foreach name="group_arr" item="vo">
									<option name="g_id" value="{$vo.class_id}">
										{$vo.class_name}</option>
								</foreach>
							</select>
						</div>
					</div>
				<?php } ?>
			</div>
			<a style="font-size: 20px; display: block;float:left;margin-left: 360px" onclick="copyHtml2()">添加+</a>
		</div>


	<div class="form-actions" style="padding-left:260px;">
		<input type="hidden" name="id" value="<?php echo $_GET['id'];?>">
	<button type="button" id="quick_publish" class="btn">下一步</button>
</div>
</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.DIMAUB;
</script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>

<script type="text/javascript" >
    $(function() {

    });


    function copyHtml2(){
		var str = '<input type="text" name="vote_class[]" style="width: 556px; margin-top: 20px;" value="" class="vote_class">';
			str += '<div class="control-group" style="margin-top:20px;"><label class="span1 control-label" style="width: 60px;text-align: left;">选择组：</label><div class="zu_span3"><select class="select_2" name="parent_id[]" id="column_type" ><foreach name="group_arr" item="vo"><option value="{$vo.class_id}">{$vo.class_name}</option></foreach></select></div></div>';
        $('#chengban').prepend(str);
	}


    function html5Reader(file, previewId){
        var file = file.files[0];
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            $('#'+previewId).attr('src', this.result);
        }
    }
    function image_change(fileId, previewId) {
        var pic = document.getElementById(previewId),
            file = document.getElementById(fileId);

        var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();

        // gif在IE浏览器暂时无法显示
        if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
            alert("图片的格式必须为png或者jpg或者jpeg格式！");
            return;
        }
        var isIE = navigator.userAgent.match(/MSIE/)!= null,
            isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

        if(isIE) {
            file.select();
            var realLocalPath = document.selection.createRange().text;

            // IE6浏览器设置img的src为本地路径可以直接显示图片
            if (isIE6) {
                pic.src = realLocalPath;
            }else {
                // 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
                pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
                // 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
                pic.src = '';
            }
        }else {
            html5Reader(file, previewId);
        }
    }

    $("#picker").click(function(){
        $("#imageFile").click();
    });

    $("#imageFile").change(function(){
        image_change('imageFile', 'imagePreview');
    });
</script>
</body>
</html>